package com.numberma.userservice.Utils;

import com.numberma.userservice.constant.JwtConstant;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class JwtUtil {
    public static String CreateJwt(Map<String, Object> map) {

        return Jwts.builder()
                .setClaims(map)
                .signWith(io.jsonwebtoken.SignatureAlgorithm.HS256, JwtConstant.JWT_SECRET)
                .setExpiration(new Date(System.currentTimeMillis() + JwtConstant.JWT_TTL))
                .compact();
    }
    public static Claims ParseJwt(String token, String secretKey) {

        return Jwts.parser()
                 .setSigningKey(secretKey)
                 .parseClaimsJws(token)
                 .getBody();
    }

}
